/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package origendatos.dyd.model;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author erodrig
 */
@Entity
@Table(name = "IDIOMAS_PJ")
@NamedQueries({
    @NamedQuery(name = "IdiomasPj.findAll", query = "SELECT i FROM IdiomasPj i"),
    @NamedQuery(name = "IdiomasPj.findByNombre", query = "SELECT i FROM IdiomasPj i WHERE i.idiomasPjPK.nombre = :nombre"),
    @NamedQuery(name = "IdiomasPj.findByPjId", query = "SELECT i FROM IdiomasPj i WHERE i.idiomasPjPK.pjId = :pjId")})
public class IdiomasPj implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected IdiomasPjPK idiomasPjPK;
    @JoinColumn(name = "PJ_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Pj pj;

    public IdiomasPj() {
    }

    public IdiomasPj(IdiomasPjPK idiomasPjPK) {
        this.idiomasPjPK = idiomasPjPK;
    }

    public IdiomasPj(String nombre, int pjId) {
        this.idiomasPjPK = new IdiomasPjPK(nombre, pjId);
    }

    public IdiomasPjPK getIdiomasPjPK() {
        return idiomasPjPK;
    }

    public void setIdiomasPjPK(IdiomasPjPK idiomasPjPK) {
        this.idiomasPjPK = idiomasPjPK;
    }

    public Pj getPj() {
        return pj;
    }

    public void setPj(Pj pj) {
        this.pj = pj;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idiomasPjPK != null ? idiomasPjPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof IdiomasPj)) {
            return false;
        }
        IdiomasPj other = (IdiomasPj) object;
        if ((this.idiomasPjPK == null && other.idiomasPjPK != null) || (this.idiomasPjPK != null && !this.idiomasPjPK.equals(other.idiomasPjPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "origendatos.dyd.model.IdiomasPj[idiomasPjPK=" + idiomasPjPK + "]";
    }

}
